package Course11;
import java.util.HashMap;
import java.util.Map;

public class Hash2 {
    public static void main(String[] args) {
        Map<String,String>hashMap=new HashMap<>();
        hashMap.put("name","张三");
        hashMap.put("name2","李四");
        hashMap.put("name3","王五");
        System.out.println("HashMap的元素个数是"+hashMap.size());

        //遍历方法1
        /*Iterator iter=hashMap1.entrySet().iterator();
        while(iter.hasNext()){
            Map.Entry name=(Map.Entry)iter.next();
            String nameKey=(String)name.getKey();
            String nameValue=(String)name.getValue();
            System.out.println(nameKey+"'s name is"+nameValue);
        }*/
        //遍历方法2
        /*hashMap1.forEach((key,value)->{
            System.out.println("[key=" + key + ",value=" + value + "]");
        })*/
    }
}
